/**
 * @author 黄波
 * 创建日期：2011Sep 3, 2011
 * TODO// N/A
 */
package com.platform.dev.action;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.platform.dev.bo.DevBo;
import com.platform.pojo.Module;

//获得所有节点信息，以Json格式返回
public class GetModulesAction extends DevSupport {

	private boolean success;
	private List<Module> modules;
	@Override
	public String execute() throws Exception {
		DevBo bo = new DevBo();
		modules = bo.getModules();
		success = true;
		HashMap map = new HashMap();
		map.put("modules", modules);
		map.put("success", success);
		JSONObject json = JSONObject.fromObject(map);
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		out.println(json.toString());
		out.flush();
		out.close();
		return null;
	}
	/**
	 * @return the success
	 */
	public boolean isSuccess() {
		return success;
	}
	/**
	 * @param success the success to set
	 */
	public void setSuccess(boolean success) {
		this.success = success;
	}
	/**
	 * @return the modules
	 */
	public List<Module> getModules() {
		return modules;
	}
	/**
	 * @param modules the modules to set
	 */
	public void setModules(List<Module> modules) {
		this.modules = modules;
	}
}
